<template>
	<view>
		<view class="stage-item" @click="goTask">
			<image class="shrink-icon" :class="{'up':shrinkType == true}" src="/static/image/push_icon.png" mode="aspectFit" v-if="shrink == true" @click="shrinkTypeChange"></image>
			<view class="item-title-box">
				<view class="num">
					{{shrink == true ? item.taskId : item.taskNo}}
				</view>
				<view class="title" :style="shrink == true ? 'font-weight: bold;' : ''">
					{{shrink == true ? item.phaseName : item.taskName}}
				</view>
				<view class="status tag" :style="" v-if="shrink == true">
					{{shrink == true ? item.timeStatus : statusList[item.executeStatus].name}}
				</view>
				<view class="leader" v-if="shrink == false">
					负责人：{{item.leader.userName}}
				</view>
			</view>
			<view class="table-box" v-if="shrink == true && shrinkType == true || shrink == false">
				<view class="table-row">
					<view class="table-item title" v-if="shrink == false">
						优先级：
					</view>
					<view class="table-item value" v-if="shrink == false">
						<view class="tag-radius" :style="{backgroundColor : numberColorList[item.priority]}">
							{{item.priority}}
						</view>
					</view>
					<view class="table-item title" v-if="shrink == false">
						重要级：
					</view>
					<view class="table-item value" v-if="shrink == false">
						<view class="tag-radius" :style="{backgroundColor : numberColorList[item.importance]}">
							{{item.importance}}
						</view>
					</view>
				</view>
				<view class="table-row">
					<view class="table-item title">
						创建日期：
					</view>
					<view class="table-item value">
						{{item.createTime ? item.createTime : '——' + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}}
					</view>
					<view class="table-item title">
						截止日期：
					</view>
					<view class="table-item value">
						{{item.endTime}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			info:{
				type:Object,
				default:{}
			},
			shrink:{
				type:Boolean,
				default:false,
			},
			borderBottom:{
				type:Boolean,
				default:false,
			},
			shrinkType:{
				type:Boolean,
				default:false,
			},
			index:{
				type:Number,
				default:0
			},
		},
		data() {
			return {
				item:{},
				statusList: [{
						id: 0,
						name: "未开始" 
					},
					{
						id: 1,
						name: "进行中",
						color:'#6ea7de',
					},
					{
						id: 2,
						name: "已暂停",
						color:'#fcad4e',
					},
					{
						id: 3,
						name: "完成提报中",
						color:'#147797',
					},
					{
						id: 4,
						name: "异常提报中",
						color:'#c8443f'
					},
					{
						id: 5,
						name: "正常完成",
						color:'#7bc094'
					},
					{
						id: 6,
						name: "异常完成",
						color:'#fe0000'
					}
				],
				numberColorList:['','#d82b58','#f53d33','#fb950d','#f0b75d','#687178'],
			}
		},
		mounted(){
			let info = this.info;
			if(info.priority){
			info.priority = info.priority.substring(0,1);
			}
			if(info.importance){
			info.importance = info.importance.substring(0,1);
			}
			if(info.createTime){
				info.createTime = info.createTime.substring(0,info.createTime.length - 3);
			}
			if(info.endTime){
				info.endTime = info.endTime.substring(0,info.endTime.length - 3);
			}
			console.log(info);
			this.item = info;
		},
		methods: {
			shrinkTypeChange:function(){
				this.$emit('shrinkTypeChange',this.index);
			},
			/**
			 * 前往任务详情
			 */
			goTask:function(){
				let shrink = this.shrink;
				if(shrink == false){
					uni.navigateTo({
						url: '/pages/mask/detail/detail?id='+ this.info.id
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.stage-item{
		padding: 20rpx 40rpx;
		padding-right:20rpx;
		box-sizing: border-box;
		width:100%;
		position:relative;
		.shrink-icon{
			position: absolute;
			top: 20rpx;
			left: 0;
			width: 40rpx;
			height: 40rpx;
		}
		.up{
			transform:rotate(180deg);
		}
		.item-title-box{
			display: flex;
			width: 100%;
			position:relative;
			.num{
				font-size: 20rpx;
				background-color: #f6f6f6;
				padding: 0 20rpx;
				line-height: 40rpx;
				border-radius: 10rpx;
			}
			.title{
				font-size: 30rpx;
				margin-left: 20rpx;
				line-height:40rpx;
			}
			.tag{
				border:1rpx solid #ea0b0b;
				font-size:24rpx;
				line-height: 36rpx;
				height:36rpx;
				padding: 0 15rpx;
				background-color:rgba(234,11,11,0.05);
				color: #ea0b0b;
				margin: 0 20rpx;
				border-radius: 10rpx;
			}
			.leader{
				background-color: #f6f6f6;
				font-size: 24rpx;
				line-height: 36rpx;
				position:absolute;
				right: 0;
				padding:0 20rpx;
				border-radius: 10rpx;
			}
		}
		.table-box{
			display: table;
			width: 100%;
			margin-top: 20rpx;
			.table-row{
				display: table-row;
			}
			.table-item{
				display: table-cell;
				line-height:40rpx;
				.tag-radius{
					border-radius: 100%;
					color: white;
					background-color: #37c315;
					width:40rpx;
					height:40rpx;
					font-size: 24rpx;
					line-height:40rpx;
					text-align: center;
				}
			}
			.table-item:nth-child(3n){
				padding-left:2%;
			}
			.value{
				font-size: 20rpx;
			}
			.title{
				font-size: 20rpx;
			}
		}
	}
</style>
